package com.runa.monitor.platinterface.extend.hdb;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 2022/10/4 15:47
 * zhangYB
 */
public class CollectionUtil {


    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.isEmpty();
    }

    public static boolean isNotEmpty(Collection<?> collection) {
        return !isEmpty(collection);
    }


    public static boolean isEmpty(Map<?, ?> map) {
        return null == map || map.isEmpty();
    }


    public static boolean isNotEmpty(Map<?, ?> map) {
        return null != map && !map.isEmpty();
    }


    public static <T, K> Map<K, T> toMap(List<T> list, Function<T, K> keyMapper) {
        return list.stream().collect(Collectors.toMap(keyMapper, Function.identity(), (e1, e2) -> e1));
    }












}
